<template>
  <Page v-slot:default="{contentClass}">
    <div :class="contentClass">
      <van-form @submit="onSubmit">
        <van-cell-group inset>
          <van-field v-model="item.money" type="number" label="金额" placeholder="请输入金额" :rules="[{ required: true, message: '请输入金额' }]" />
        </van-cell-group>
        <div style="margin: 16px;">
          <van-button round block type="primary" native-type="submit">
            提交
          </van-button>
        </div>
      </van-form>
    </div>
  </Page>
</template>

<script setup>
import {ref} from 'vue';
import {useStore} from "vuex";
import {useRoute, useRouter} from "vue-router";
import Page from "../components/Page.vue"
import {computed, onMounted, watch} from "vue";

import apis from '../apis'
import app from "../configs/app";

const store = useStore()
const router = useRouter()
const route = useRoute()

const item = ref({
  type: "test",
  money: null,
})
const onSubmit = (values) => {
  apis.order.store(item.value).then(({data: result}) => {
    location.href = app.payUrl + "?order_id=" + result.data.id + "&back_url=" +  encodeURIComponent(location.href)
  })
}
</script>

<style scoped>

</style>